<template>
	<div>
		<headerNave :nva-datas="navDatas" v-on:backNav="backNav"></headerNave>
		<components :is="currentView" v-on:changeView="changeView" v-on:backPrev="backPrev" :template-obj="templateObj"></components>
	</div>
</template>
<script>
	import $ from 'jquery'
	import headerNave from '../../../../components/headerNave'
	import { GloabFun, Animation, HttpServer } from '../../../../assets/js/common.js'
	//设备列表
	const List = resolve => require(['./List.vue'], resolve)
	//WT01设备详情
	const WTDetail = resolve => require(['./WTDetail.vue'], resolve)
	//微图监控抓拍图片列表
	const WTMachineCapture = resolve => require(['./MachineCaptureList.vue'], resolve)
	//自助借还书机详情
	const AutoBookRacksDetail = resolve => require(['./AutoBookRacksDetail.vue'], resolve)
	//自助借还机抓拍图片列表
	const AutoCapture = resolve => require(['./AutoCaptureList.vue'], resolve)
	//TC1000中控设备详情
	const TC1000Detail = resolve => require(['./TC1000Detail.vue'], resolve)
	//安全门设备详情
	const SecureGateDetail = resolve => require(['./SecureGateDetail.vue'], resolve)
	//监控详情
	const HKDetail = resolve => require(['./HKDetail.vue'], resolve)
	//ZigBee设备详情
	const ZigBeeDetail = resolve => require(['./ZigBeeDetail.vue'], resolve)
	//智能书架详情
	const ZNSJDetail = resolve => require(['./ZNSJDetail.vue'], resolve)
	//智慧空开详情
	const EBoxDetail = resolve => require(['./EBoxDetail.vue'], resolve)
	//图书角详情
	const BookCornerDetail = resolve => require(['./BookCornerDetail.vue'], resolve)
	//地图
	const mapSet = resolve => require(['./Map.vue'], resolve)
	//电脑画面
	const pcDetail = resolve => require(['./PCDetail.vue'], resolve)
	//灯控制
	const lightControl = resolve => require(['./LightList.vue'], resolve)
	//投影机/一体机控制
	const projectorControl = resolve => require(['./ProjectorList.vue'], resolve)
	//空调控制
	const airConditionControl = resolve => require(['./AirConditionList.vue'], resolve)
	//智能终端定时关机（计划任务）
	const IntelligenceTimeClose = resolve => require(['./IntelligenceTimeClose/List.vue'], resolve)
	const AddIntelligenceTimeClose = resolve => require(['./IntelligenceTimeClose/Add.vue'], resolve)
	const EditIntelligenceTimeClose = resolve => require(['./IntelligenceTimeClose/Edit.vue'], resolve)
	export default {
		components: {
			List,
			WTDetail,
			headerNave,
			TC1000Detail,
			SecureGateDetail,
			AutoBookRacksDetail,
			AutoCapture,
			HKDetail,
			ZigBeeDetail,
			ZNSJDetail,
			EBoxDetail,
			mapSet,
			pcDetail,
			IntelligenceTimeClose,
			AddIntelligenceTimeClose,
			EditIntelligenceTimeClose,
			lightControl,
			projectorControl,
			airConditionControl,
			WTMachineCapture,
			BookCornerDetail
		},
		data() {
			return {
                isMob: false,
				currentView: "List",
				templateObj: {
					DistrictId: this.subArgs.DistrictId,
					CurrentView: this.subArgs.CurrentView
				},
				navDatas: [{
					name: '设备管理',
					view: ""
				},
				{
					name: this.subArgs.CurrentView,
					view: "List"
				}
				]
			};
		},
		props: {
			subArgs: {
				type: Object,
				default: {}
			}
		},
		methods: {
			changeView(view, obj) {
				GloabFun.clearRecordPreview.call(this);
				obj.CurrentView = this.subArgs.CurrentView;
				Animation.animation($("#mainContent"), function() {
					if(obj) {
						this.navDatas = [{
							name: '设备管理',
							view: ""
						}, {
							name: this.subArgs.CurrentView,
							view: "List"
						}];
						this.templateObj = obj;
						if(view === "WTDetail") {
							this.navDatas.push({
								name: "设备详情->" + obj.name + "-" + obj.model + "-" + (obj.online ? '在线' : '离线'),
								view: "WTDetail"
							});
						} else if(view === 'BookCornerDetail') {
							this.navDatas.push({
								name: "设备详情->" + obj.name + "-" + obj.model + "-" + (obj.online ? '在线' : '离线'),
								view: "BookCornerDetail"
							});
						}else if(view === 'AutoBookRacksDetail') {
							this.navDatas.push({
								name: "设备详情->" + obj.name + "-" + obj.model + "-" + (obj.online ? '在线' : '离线'),
								view: "AutoBookRacksDetail"
							});
						} else if(view === 'TC1000Detail') {
							this.navDatas.push({
								name: "设备详情->" + obj.name + "-" + obj.model + "-" + (obj.online ? '在线' : '离线'),
								view: "TC1000Detail"
							});
						} else if(view === "SecureGateDetail") {
							this.navDatas.push({
								name: "设备详情->" + obj.name + "-" + obj.model + "-" + (obj.online ? '在线' : '离线'),
								view: "SecureGateDetail"
							});
						} else if(view === "HKDetail") {
							this.navDatas.push({
								name: "设备详情->" + obj.name + "-" + obj.model + "-" + (obj.online ? '在线' : '离线'),
								view: "HKDetail"
							});
						} else if(view === "ZigBeeDetail") {
							this.navDatas.push({
								name: "设备详情->" + obj.name + "-" + obj.model + "-" + (obj.online ? '在线' : '离线'),
								view: "ZigBeeDetail"
							});
						} else if(view === 'ZNSJDetail') {
							this.navDatas.push({
								name: "设备详情->" + obj.name + "-" + obj.model + "-" + (obj.online ? '在线' : '离线'),
								view: "ZNSJDetail"
							})
						}else if(view === 'EBoxDetail') {
							this.navDatas.push({
								name: "设备详情->" + obj.name + "-" + obj.model + "-" + (obj.online ? '在线' : '离线'),
								view: "EBoxDetail"
							})
						}else if(view === "mapSet") {
							this.navDatas.push({
								name: "设备详情->" + obj.name + "-" + obj.model + "-" + (obj.online ? '在线' : '离线'),
								view: "WTDetail"
							});
							this.navDatas.push({
								name: "位置设置",
								view: "mapSet"
							});
						} else if(view === "pcDetail") {
							this.navDatas.push({
								name: "设备详情->" + obj.name + "-" + obj.model + "-" + (obj.online ? '在线' : '离线'),
								view: "pcDetail"
							});
						} else if(view === "IntelligenceTimeClose") {
							this.navDatas.push({
								name: "智能终端定时任务",
								view: "IntelligenceTimeClose"
							});
						} else if(view === "AddIntelligenceTimeClose") {
							this.navDatas.push({
								name: "智能终端定时任务",
								view: "IntelligenceTimeClose"
							});
							this.navDatas.push({
								name: "创建",
								view: "AddIntelligenceTimeClose"
							});
						} else if(view === "EditIntelligenceTimeClose") {
							this.navDatas.push({
								name: "智能终端定时任务",
								view: "IntelligenceTimeClose"
							});
							this.navDatas.push({
								name: "编辑->" + obj.Name,
								view: "EditIntelligenceTimeClose"
							});
						} else if(view === "lightControl") {
							this.navDatas.push({
								name: "照明设备",
								view: "lightControl"
							});
						}else if(view === "projectorControl"){
							this.navDatas.push({
								name: "投影机/一体机",
								view: "projectorControl"
							});
						}else if(view === "airConditionControl") {
							this.navDatas.push({
								name: "空调",
								view: 'airConditionControl'
							})
						}else if(view === "WTMachineCapture"){
							this.navDatas.push({
								name: "设备详情->" + obj.name + "-" + obj.model + "-" + (obj.online ? '在线' : '离线'),
								view: "WTDetail"
							});
							this.navDatas.push({
								name: "设备监控图片",
								view: "WTMachineCapture"
							});
						}else if(view === "AutoCapture"){
							this.navDatas.push({
								name: "设备详情->" + obj.name + "-" + obj.model + "-" + (obj.online ? '在线' : '离线'),
								view: "AutoBookRacksDetail"
							});
							this.navDatas.push({
								name: "设备监控图片",
								view: "AutoCapture"
							});
						}
					}
					this.currentView = view;
				}.bind(this));
			},
			backPrev() {
				this.$emit('backPrev');
			},
			backNav(item) {
				if(item.view === "List") {
					this.changeView("List", this.templateObj);
				} else if(item.view === "WTDetail") {
					this.changeView("WTDetail", this.templateObj);
				} else if(item.view === "IntelligenceTimeClose") {
					this.changeView("IntelligenceTimeClose", this.templateObj);
				} else if(item.view === "AutoBookRacksDetail"){
					this.changeView("AutoBookRacksDetail", this.templateObj);
				}
			}
		},
		created() {
			// console.log(11,this.subArgs)
		}
	}
</script>